package com.zh.note.huawei.onehundred.喊7的次数重排;

import java.util.Arrays;

/**
 * @Author: zhanghuan
 * @date: 2023/8/31 09:40
 * @description: create it
 */
public class Main {
    public static void main(String[] args) {
        // Scanner sc = new Scanner(System.in);
        // String str = sc.nextLine();
        String str = "0 0 0 2 1";
        String[] input = str.split(" ");
        if (str.length() == 1) {
            System.out.println(input[0]);
            return;
        }
        int[] nums = Arrays.stream(input).mapToInt(Integer::parseInt).toArray();
        //喊7的次数
        int sum = Arrays.stream(nums).sum();
        //找出喊了哪几个数
        int[] sevenNums = findSevenNums(sum);
        int length = nums.length;
        int[] res = new int[length];
        for (int num : sevenNums) {
            //计算数组下标
            int index = (num % length + length - 1) % length;
            res[index]++;

        }
        for (int i = 0; i < length; i++) {
            System.out.print(res[i]);
            if (i != length - 1) {
                System.out.print(" ");
            }
        }
    }

    //找到喊过的数
    private static int[] findSevenNums(int times) {
        // 数组下标
        int index = 0;
        // 模拟加1的数据
        int num = 1;
        int[] res = new int[times];
        while (times > index) {
            if (num % 7 == 0 || String.valueOf(num).contains("7")) {
                res[index] = num;
                index++;

            }
            num++;
        }
        return res;
    }
}
